package com.aner.test.controller;
import com.aner.tester.controller.BaseControllerTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.aner.tester.utils.text.StringUtils;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * RequestTestControllerTest class
 * 
 * @author aner
 * @date 2020-12-27
 */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class RequestTestControllerTest extends BaseControllerTest
{

    @Test
    public void testTest() {
        String params = "{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:35','doubleTest':0.1318233634563738,'floatTest':0.49878746,'intTest':1,'longTest':3,'stringTest':'司猫事尔'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/test/", jsonStr);
        
    }
    @Test
    public void testRequestBodyMapTest() {
        String params = "{'4东猪25广':'18','广故猪安省广':'744','告40小':'629','3猫猫小':'5365','小小':'2124','小个事公小':'111112'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyMap/", jsonStr);
        
    }
    @Test
    public void testRequestBodyListTest() {
        String params = "['4个的','小尔','事故']";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyList/", jsonStr);
        
    }
    @Test
    public void testRequestBodyLongTest() {
        String params = "2";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyLong/", jsonStr);
        
    }
    @Test
    public void testRequestParamListTest() {
        String params = "{'testList':['小尔省2狗','东广个','的个省狗','事的的公']}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testRequestParamList/", jsonStr);
        
    }
    @Test
    public void testRequestParamDateTest() {
        String params = "{'testDate':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testRequestParamDate/", jsonStr);
        
    }
    @Test
    public void testRequestBodyDateTest() {
        String params = "1609075716072";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBodyDate/", jsonStr);
        
    }
    @Test
    public void testDateTest() {
        String params = "{'test':'2020-12-27 21:28:36'}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testDate/", jsonStr);
        
    }
    @Test
    public void testBodyTest() {
        String params = "{'booleanTest':false,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.7565140888947927,'floatTest':0.7479892,'intTest':1,'longTest':2,'strArray':['猪2猪猫','小三司','狗的猪个4','三广','猫事事事的0'],'stringList':['小2的','小司个的告','猫广广小猪4','尔告尔5','的司小四'],'stringTest':'事猪个','testObjectArray':[{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.4132200989528326,'floatTest':0.0039746165,'intTest':0,'longTest':0,'stringTest':'3猪小'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.7507737274544091,'floatTest':0.30729795,'intTest':1,'longTest':1,'stringTest':'0小小司狗4'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.3556885923179245,'floatTest':0.27941024,'intTest':1,'longTest':0,'stringTest':'安个司尔猫'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.044868873206730386,'floatTest':0.97452736,'intTest':1,'longTest':3,'stringTest':'3狗猫2第'},{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.01647615309860806,'floatTest':0.3914935,'intTest':1,'longTest':0,'stringTest':'猫小'}],'testObjectList':[{'booleanTest':true,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.25871807323265217,'floatTest':0.10700983,'intTest':0,'longTest':3,'stringTest':'狗小55狗公'},{'booleanTest':true,'byteTest':1,'dateTest':'2020-12-27 21:28:36','doubleTest':0.3610053290192491,'floatTest':0.9062301,'intTest':1,'longTest':0,'stringTest':'东广的广'},{'booleanTest':false,'byteTest':0,'dateTest':'2020-12-27 21:28:36','doubleTest':0.023841478815722406,'floatTest':0.6485582,'intTest':1,'longTest':1,'stringTest':'的小0'}],'testObjectMap':{'小告告狗司':'56','小1四狗3':'80'}}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.requestBody("/testRequestBody/", jsonStr);
        
    }
    @Test
    public void testPathVariableTest() {
        String params = "{'params':['3广四猪02','4东广猪'],'id':[2,3,3,3]}";
        String jsonStr = StringUtils.replaceSingleQuoteWithDouble(params);
                    this.request("/testPathVariable/{params}/{id}", jsonStr);
        
    }
}
